/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.univali.sindico.mb;

import br.univali.sindico.dao.*;
import br.univali.sindico.entity.*;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author Fernando
 */
@ManagedBean
@RequestScoped
public class ReservaAmbienteMB {
    
    private AmbienteDAO ambienteDAO;
    private ReservaAmbienteDAO reservaAmbienteDAO;
    private MoradorDAO moradorDAO;
    
    private ReservaAmbiente reservaAmbiente;
    
    private List<ReservaAmbiente> reservaAmbienteList;
    private List<Ambiente> ambienteList;

    public ReservaAmbienteMB() {
        reservaAmbienteDAO = new ReservaAmbienteDAO();
        reservaAmbiente = new ReservaAmbiente();
        reservaAmbienteList = new ArrayList<ReservaAmbiente>();
        ambienteDAO = new AmbienteDAO();
        moradorDAO = new MoradorDAO();
    }    
    
    public void save(){
//        reservaAmbiente.setCodigoMorador(new Morador());
//        reservaAmbiente.getCodigoMorador().setCodigoPessoa(1L);
//        reservaAmbienteDAO.save(reservaAmbiente);
//        clean();
    }
    
    public void validate(){
//        reservaAmbiente.setCodigoMorador(new Morador());
//        reservaAmbiente.getCodigoMorador().setCodigoPessoa(1L);
//        reservaAmbienteDAO.save(reservaAmbiente);
    }

    public ReservaAmbiente getReservaAmbiente() {
        return reservaAmbiente;
    }

    public void setReservaAmbiente(ReservaAmbiente reservaAmbiente) {
        this.reservaAmbiente = reservaAmbiente;
    }

    public ReservaAmbienteDAO getReservas() {
        return reservaAmbienteDAO;
    }

    public void setReservas(ReservaAmbienteDAO reservaAmbienteDAO) {
        this.reservaAmbienteDAO = reservaAmbienteDAO;
    }

    public List<ReservaAmbiente> getReservaAmbienteList() {
        reservaAmbienteList = reservaAmbienteDAO.getAll();
        if(reservaAmbienteList != null && reservaAmbienteList.size()>0){
            return reservaAmbienteList;
        } else {
            return new ArrayList<ReservaAmbiente>();
        }
    }

    public void setReservaAmbienteList(List<ReservaAmbiente> reservaAmbienteList) {
        this.reservaAmbienteList = reservaAmbienteList;
    }

    public List<Ambiente> getAmbienteList() {
        ambienteList = ambienteDAO.getAll();
        if(ambienteList != null && ambienteList.size()>0){
            return ambienteList;
        } else {
            return new ArrayList<Ambiente>();
        }
    }
    
    public void setAmbienteList(List<Ambiente> ambienteList) {
        this.ambienteList = ambienteList;
    }   
    
    public void clean(){
        reservaAmbiente = new ReservaAmbiente();
    }
    
}
